home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / RCS / bsearch.man,v < prev    next >
Encoding:
Text File  |  1989-02-19  |  1.5 KB  |  70 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.1
  10. date     89.02.18.20.38.40;  author rab;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @'\" Copyright 1989 Regents of the University of California
  26. '\" Permission to use, copy, modify, and distribute this
  27. '\" documentation for any purpose and without fee is hereby
  28. '\" granted, provided that this notice appears in all copies.
  29. '\" The University of California makes no representations about
  30. '\" the suitability of this material for any purpose.  It is
  31. '\" provided "as is" without express or implied warranty.
  32. '\" 
  33. '\" $Header$
  34. '/" 
  35. .so \*(]ltmac.sprite
  36. .HS bsearch lib
  37. .BS
  38. .SH NAME
  39. bsearch \- Binary search
  40. .SH SYNOPSIS
  41. .nf
  42. \fBvoid *bsearch(key, base, n, size, cmp)
  43. .SH ARGUMENTS
  44. .AS size_t base
  45. .AP void *key;
  46. Pointer to the object being searched for.
  47. .AP void *base;
  48. Pointer to the base of the array to search.
  49. .AP size_t n;
  50. Number of items in the array.
  51. .AP size_t size;
  52. Size of each item.
  53. .AP int (*cmp)();
  54. Function to compare two items.
  55. .BE
  56.  
  57. .SH DESCRIPTION
  58. .PP
  59. \fBBsearch\fR searches \fBbase[0] ... base[n - 1]\fR for an item
  60. that matches \fB*key\fR.  The function \fBcmp\fR must return
  61. negative if its first argument (the search key) is less than
  62. its second (a table entry), zero if equal, and positive if greater.
  63. Items in the array \fBbase\fR must be in ascending order.  \fBbsearch\fR
  64. returns a pointer to a matching item, or \fBNULL\fR if none exits.
  65.  
  66. .SH KEYWORDS
  67. search
  68.  
  69. @
  70.